﻿@{
    Layout = null;
}
@Html.Action("Account_Show", "Account");
<div class="content">
    <div class="right" id="mainFrame">
        <div class="right_cont">
            <div class="header">
                <div class="header-right">
                    <form method="post">
                        <div id="modal-container-973559" class="modal hide fade" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="width:400px; margin-left:-150px;">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                <h3 id="myModalLabel">
                                    区域新增系统
                                </h3>
                            </div>
                            <div class="modal-body">

                                <table class="table table-hover table-bordered " style="width:400px;text-align:center;margin:0 auto;border:2px solid #428bca;">

                                    <tbody>

                                        <tr>

                                            <th>省份</th>
                                            <td>@Html.DropDownList("Locality_id", "--请选择--")</td>
                                        </tr>

                                        <tr>
                                            <th>市区</th>
                                            <td>@Html.TextBox("Locality_sheng")</td>
                                        </tr>
                                    </tbody>
                                </table>

                            </div>
                            <div class="modal-footer">
                                <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button> <button type="button" class="btn btn-default" onclick="fun()"><span class="icon-inbox"></span>保存</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

            <div id="middle">
                <div class="Switch"></div>
                <script type="text/javascript">
                    $(document).ready(function (e) {
                        $(".Switch").click(function () {
                            $(".left").toggle();

                        });
                    });
                </script>

                <div class="right" id="mainFrame">

                    <div class="right_cont">
                        <ul class="breadcrumb">
                            当前位置：
                            <a href="/Home/Index">首页</a>
                            <span class="divider">/</span>
                            区域管理
                        </ul>
                        <div class="title_right"><strong>区域管理</strong></div>
                        <div style="width:100%; margin:auto">
                            <div>
                                <form action="/Custom_Info/Serach_Custom_Info" method="get">
                                    <table>
                                        <tr>
                                            <td><button id="modal-973559" href="#modal-container-973559" role="button" type="button" class="btn btn-default" data-toggle="modal"><span class="icon-plus"></span>新增</button></td>
                                        </tr>
                                    </table>
                                </form>
                            </div>
                            <div style="margin-top:20px;">
                                <table class="table  table-hover table-bordered table-striped">
                                    <thead>
                                        <tr>
                                            <th>省份</th>
                                            <th>市区</th>

                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td>
                                                <select id="Select1">
                                                    <option>--请选择--</option>

                                                </select>
                                            </td>
                                            <td>
                                                <select id="Select2">
                                                    <option>--请选择--</option>

                                                </select>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        $.ajax({
            url: "/Locality/GetLocality",
            type: "get",
            data: {
                Provice: 0
            },
            success: function (data) {

                $(data).each(function (a, c) {
                    var option = "";
                    option += '<option value="' + c.P_Id + '">' + c.P_Name + '</option>';
                    $("#Select1").append(option);
                })
            }
        })
    })
    $("#Select1").change(function () {
        $.ajax({
            url: "/Locality/GetLocality",
            type: "get",
            data: {
                Provice: $("#Select1").val()
            },
            success: function (data) {
                $("#Select2").empty();
                $(data).each(function (a, c) {
                    var option = "";
                    option += '<option value="' + c.P_Id + '">' + c.P_Name + '</option>';
                    $("#Select2").append(option);
                })
            }
        })
    })
    function fun() {

        var por = "";

        var dropDownList = document.getElementById("Locality_id"); //获取DropDownList控件

        var dropDownListValue = dropDownList.options[dropDownList.selectedIndex].value;
        var ss = $("#Locality_sheng").val();
        if (dropDownListValue == "") {
            por = 0;
        }
        else {
            por = dropDownListValue;
        }
        if (ss == "") {
            alert("信息不能为空!");
            return;
        }

        $.ajax({
            type: "post",
            url: "/Locality/AddLocality",
            data: {
                dropDownListValue: por,
                ss: ss
            },
            success: function (data) {
                if (data == "True") {
                    alert("OK");
                    location.reload();
                }
                else {
                    alert("No");
                }
            }
        })
    }
</script>
